package com.spring.shiro.config;

import com.spring.shiro.service.CxfService;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.xml.ws.Endpoint;


@Configuration
public class CxfConfig {

    @Autowired
    SpringBus springBus;

    @Autowired
    CxfService cxfService;

    /**
       * 此方法作用是改变项目中服务名的前缀名，此处127.0.0.1或者localhost不能访问时
       * 此方法被注释后:wsdl访问地址为http://127.0.0.1:8080/services/cxf?wsdl
       * 去掉注释后：wsdl访问地址为：http://127.0.0.1:8080/soap/cxf?wsdl
       * @return
       */
//     @Bean
//     public ServletRegistrationBean servletRegistrationBean() {
//        ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/soap/*");
//        bean.setLoadOnStartup(0);
//        bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
//        return bean;
//     }

    /** JAX-WS
     * 站点服务
     **/
     @Bean
     public Endpoint endpoint() {
         EndpointImpl endpoint = new EndpointImpl(springBus, cxfService);
         //endpoint.getInInterceptors().add(new AuthInterceptor());//添加校验拦截器
         endpoint.publish("/cxf");
         return endpoint;
     }


}
